<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>新闻列表</title>
<meta name="keywords" content="新闻关键字优化" />
<meta name="description" content="新闻描述优化" />
<meta name="applicable-device"content="pc,mobile">
<link href="/static/website/css/bootstrap.css" rel="stylesheet">
<link href="/static/website/css/bxslider.css" rel="stylesheet">
<link href="/static/website/css/style.css" rel="stylesheet">
<script src="/static/website/js/jquery.min.js"></script>
    <script src="/static/website/js/bxslider.min.js"></script>
    <script src="website/js/common.js"></script>
    <script src="/static/website/js/bootstrap.js"></script>
    <!--[if lt IE 9]><script src="website/js/html5shiv.min.js"></script>
<script src="/static/website/js/respond.min.js"></script><![endif]-->
</head>

<body>
<header>
{% include "website/header.html"%}
</header>
<!-- main -->
<div class="container">
  <div class="row"><!-- right -->
    <div class="col-xs-12 col-sm-8 col-md-9" style="float:right">
      <div class="list_box">
        <h2 class="left_h1">新闻中心</h2>
        <ul class="list_news">
          {% for news in newslist%}
		  <li><a href="/website/shownews/{{news.id}}" title="{{news.title}}">{{news.title}}</a><span class="news_time">{{news.update_time}}</span></li>
           {% endfor%}
        
        </ul>
        <div class="page">
             <div class="pagelist">
            <!-- 上一页按钮 - 如果是第一页则禁用 -->
            {% if current_page == 1 %}
              <span class="disabled">上一页</span>
            {% else %}
              <a href="/website/news/{{ current_page|add:"-1"  }}">上一页</a>
            {% endif %}

            <!-- 页码列表 -->
            {% if total_pages > 1 %}
              <!-- 显示第一页 -->
              <a href="/website/news/1" {% if current_page == 1 %}class="current"{% endif %}>1</a>

              <!-- 省略号逻辑 -->
              {% if current_page > 3 %}
                <span>...</span>
              {% endif %}

              <!-- 显示当前页附近的页码 -->
              {% for i in page_range %}
                {% if i > 1 and i < total_pages %}
                  <a href="/website/news/{{ i }}" {% if current_page == i %}class="current"{% endif %}>{{ i }}</a>
                {% endif %}
              {% endfor %}

              <!-- 省略号逻辑 -->
              {% if current_page < total_pages|add:"-2" %}
                <span>...</span>
              {% endif %}

              <!-- 显示最后一页 -->
              {% if total_pages > 1 %}
                <a href="/website/news/{{ total_pages }}" {% if current_page == total_pages %}class="current"{% endif %}>{{ total_pages }}</a>
              {% endif %}
            {% endif %}

            <!-- 下一页按钮 - 如果是最后一页则禁用 -->
            {% if current_page == total_pages %}
              <span class="disabled">下一页</span>
            {% else %}
              <a href="/website/news/{{ current_page|add:"+1" }}">下一页</a>
            {% endif %}

            <!-- 跳页功能 -->
            <span class="page-info">
              共 {{ total_pages }} 页，{{ total_records }} 条记录
              <input type="text" id="jumpPage" size="3" value="{{ current_page }}">
              <button type="button" onclick="jumpToPage({{ total_pages }})">跳转</button>
            </span>
          </div>

        </div>
      </div>
    </div>
    <!-- left -->
     <script>
         // 跳页功能实现
function jumpToPage(totalPages) {
  var page = parseInt($("#jumpPage").val());
  // 验证输入的页码是否有效
  if (isNaN(page) || page < 1 || page > totalPages) {
    alert("请输入有效的页码!");
    $("#jumpPage").val("{{ current_page }}"); // 恢复当前页码
    return false;
  }
  // 跳转到指定页
  window.location.href = "/website/news/" + page;
}

// 为页码输入框添加回车键触发跳页
$("#jumpPage").keypress(function(e) {
  if (e.keyCode === 13) {
    jumpToPage({{ total_pages }});
    return false;
  }
});

     </script>
   {% include "website/left.html"%}
</div>{% include "website/footer.html"%}